from flask import Flask
from flask_uploads import UploadSet, IMAGES, AUDIO, DOCUMENTS, ARCHIVES, TEXT
from flask_uploads import configure_uploads, patch_request_class
from flask import current_app

IMAGES = tuple('jpg jpe jpeg png gif svg bmp webp pdf'.split())
AUDIO = tuple('wav mp3 aac ogg oga flac mp4 mov flv avi'.split())
DOCUMENTS = tuple('rtf odf ods gnumeric abw doc docx xls xlsx ppt pptx cvs txt'.split())
ARCHIVES = tuple('gz bz2 zip tar tgz txz 7z rar pdf'.split())
photos = UploadSet('photos', IMAGES)
files = UploadSet('files', DOCUMENTS + AUDIO + ARCHIVES)


def init_upload(app: Flask):
    configure_uploads(app, [photos, files])
